h, sh, m, t = 2, 12, 0, {
    hour = 11,
    min = 10
}
if sh > 0 then nextHH = h + sh end
m = m + t.min -- 加上现在的分钟
nextMM = m % 60
-- nextHH = math.floor(m / 60) + h + t.hour
if nextHH >= 24 then nextHH = nextHH - 24 end
print(nextHH, nextMM)

--- 设定闹钟
---@param h 几点开始
---@param m 间隔时间？分钟
function setClock(h, m)
    if not m then return false end
    -- 1、获取当前时间
    local t = read_time()
    if not t then return end
    -- 2、计算下次的启动时间
    local nextHH, nextMM
    m = m + t.min -- 加上现在的分钟
    nextMM = m % 60
    nextHH = bit.band(math.floor(m / 60) + h, 0xff)
    if (nextHH >= 24) then nextHH = 0 end
    -- 清除闹钟标志并开启闹钟
    i2c_send({REG_AIE, 0x02})
    -- 设置闹钟时间 时&分
    i2c_send({REG_M_ALARM, hex_to_bcd(nextMM), hex_to_bcd(nextHH)})
    -- 判断是否设定成功
    local alarm = i2c_recv(REG_M_ALARM, 2)
    log.warn(log_prefix, '读取设定的时间:' .. string.toHex(alarm, ' '))
    if bcd_to_hex(alarm:byte(1)) == nextMM and bcd_to_hex(alarm:byte(2)) == nextMM then
        log.warn(log_prefix, string.format("设定闹钟成功,下次启动时间:%d点%d分", nextHH, nextMM))
        return true
    end
    log.error(log_prefix, string.format("设定闹钟失败,%d点%d分", nextHH, nextMM))
    return false
end